﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DocuServe.Core.Entities;
using DocuServe.Data;
using NHibernate.Criterion;

namespace DocuServe.Core.Service
{
    public class CmsAttributeService
    {
        #region CmsAttributeService : Constructors.
        public CmsAttributeService()
        {
            this.Repository = new Repository<CmsAttribute>();
        }
        #endregion

        #region CmsAttributeService : Properties.
        protected Repository<CmsAttribute> Repository { get; set; }
        #endregion

        #region CmsAttributeService : Methods.
        public void Delete(int id)
        {
            using (RepositoryScope scope = RepositoryScope.Start())
            {
                CmsAttribute attribute = this.Repository.GetByID(id);
                if (attribute != null)
                    this.Repository.Delete(attribute);
                scope.Commit();
            }
        }

        public IList<CmsAttribute> GetCmsAttributes()
        {
            return this.Repository.List(DetachedCriteria.For<CmsAttribute>());
        }

        public void SaveCmsAttribute(CmsAttribute attribute)
        {
            this.Repository.Save(attribute);
        }
        #endregion
    }
}
